﻿using System;
using System.Collections.Generic;
using UnityEngine;
using DashFire;
using LitJson;

namespace DashFire
{
  public enum GameEventCode : int
  {
    Begin = 101,
    GameStart = 0,
    PlayerCG = 1,
    CheckUpdate = 2,
    CheckResult = 3,
    StartUpdate = 4,
    EndUpdate = 5,
    StartExtract = 6,
    EndExtract = 7,
    LoadAssets = 8,
    EndAssets = 9,
    ServerList = 10,
    StartLogin = 11,
    EndLogin = 12,
    VerifyToken = 13,
    VerifyResult = 16,
    ShowHeroUI = 17,
    SelectHero = 18,
    CreateHero = 19,
    CreateResult = 21,
    PlayHeroMovie = 22,
    EnterGuides = 23,
    EnterCity = 24,
  }
  public class NormLog
  {
    public void Record(GameEventCode code)
    {
      if (CanPush) {
        if (m_PushQueue.Count > 0) {
          m_PushQueue.Enqueue(code);
          while (m_PushQueue.Count > 0) {
            GameEventCode assit = m_PushQueue.Dequeue();
            PushLog(assit);
          }
        } else {
          PushLog(code);
        }
      } else {
        m_PushQueue.Enqueue(code);
      }
    }

    public void PushLog(GameEventCode code)
    {
      string str = Convert.ToString((int)code);
      //CYMGConnector.OnMBIGameEvent(str);
      LogicForGfxThread.LogicLog("cmbi gameevent : {0}->{1}", str, code);
    }

    private Queue<GameEventCode> m_PushQueue = new Queue<GameEventCode>();
    public bool CanPush = false;
    public int ServerId = 0;
    public string ServerName = "";
    public string HardwareName { get; set; }
    public string Userid { get; set; }
    static private NormLog m_Instance = new NormLog();
    static public NormLog Instance
    {
      get { return m_Instance; }
    }
  }
}
